home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------
- // ext vars
- // @szATCmd - str (LPSTR)
- // @szCID - str
- // @szDCS - str
- // @szDIS - str
- // @szDCC - str
- // @szHNG - str
- // @szNSF - str
- // @lpszRespBuff - str
- // @lPageCnt - long
- // @lPageTotal - long
- // @lSizeForNSF - long
- // @ComIO
- // @GlStr1
- // @GlStr2
- // @RespBuffer
- //---------------------------------------------------------
-
-
- //---------------------------------------------------------
- // ext functions
- //fSetBaudRate(DWORD lpParam, DWORD Baud, DWORD dwN1, DWORD dwN2);
- //fWaitResponse(DWORD lpParam, DWORD lpBuf, DWORD lTimeOut, DWORD dwN1);
- //fSendATCmd(DWORD lpParam, DWORD lpBuf, DWORD dwN1, DWORD dwN2);
- //fSendDLE_ETX(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSleep(DWORD lTime, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fFlushRxQueue(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fFlushTxQueue(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSendOneChar(DWORD lpParam, DWORD dwCh, DWORD dwN1, DWORD dwN2);
- //fWaitOneChar(DWORD lpParam, DWORD lpResultChar, DWORD lTimeOut, DWORD dwN1);
- //fSetDTR(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fResetDTR(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSetRTS(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fResetRTS(DWORD lpParam, DWORD dwN1, DWORD dwN2, DWORD dwN3);
- //fSetMisc(DWORD lpParam, DWORD nParity, DWORD nDataBits, DWORD nStopBits);
- //fSetMiscMore(DWORD lpParam, DWORD bDTRDSR, DWORD bRTSCTS, DWORD bXONXOFF);
- //fHardFlowControl(DWORD lpParam, DWORD Type, DWORD dwN1, DWORD dwN2);
- //fSoftFlowControl(DWORD lpParam, DWORD Type, DWORD dwN1, DWORD dwN2);
- //fSkipSpaceStrStr(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
- //fTxFirstResponseError(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
- //fStripChar(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
- //fFirstNumString(DWORD s1, DWORD s2, DWORD dwN1, DWORD dwN2);
- //
- // For fHardFlowControl:
- // param1 - 0000X0YY X - Cts flow control
- // YY : 00 - RTS DISABLE
- // YY : 01 - RTS ENABLE
- // YY : 10 - RTS HANDSHAKE
- // YY : 11 - RTS TOGGLE
- // For fSoftFlowControl
- // FLOWCTRL_NONE 0
- // FLOWCTRL_SEND 1
- // FLOWCTRL_RECV 2
- // FLOWCTRL_BOTH 4
- //---------------------------------------------------------
-
- //
- // This is the script file for Class2.
- //
- // trace
- declare STRING %szStr1, %szStr2;
- declare STRING %szStr3, %szStr4;
- declare STRING %szPass1, %szPass2;
- declare STRING %szPass3, %szPass4;
- declare STRING %szMsg1;
- declare long %lType;
- declare long %lRes;
- declare long %lTemp;
- declare long %lGRes;
- declare long %lMsg1;
- declare char %XON;
- declare STRING %szNULL;
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- sub SubSendCmdWaitResp(STRING #szCmd, STRING #szResp, long #lWaitTime)
- declare long %lRes;
- declare STRING %szCheckAT;
-
- %szCheckAT = "AT"
- %lRes = fSkipSpaceStrStr(%szCheckAT, #szCmd)
- if (%lRes = 0)
- {
- %lRes = 0
- goto SendCmd1
- }
-
- %lRes = fSendATCmd(@ComIO, #szCmd)
- if (%lRes!=0)
- {
- %lRes = 101
- goto SendCmd1
- }
-
-
- :SendCmd0
- %lRes = fWaitResponse(@ComIO, #lWaitTime)
- if (%lRes != 0)
- {
- %lRes = 101
- goto SendCmd1
- }
-
- %lRes = fSkipSpaceStrStr(#szResp, @RespBuffer)
- if (%lRes != 0)
- %lRes = 0
- else
- goto SendCmd0
-
- :SendCmd1
- %lGRes = %lRes
- endsub
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- :GET_CLASS1_SPEED
- fSleep(300)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- call SubSendCmdWaitResp("AT+FCLASS=1", "OK", 3000)
- fSleep(300)
- fSetBaudRate(@ComIO, 19200)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- @szATCmd = "AT+FRM=?"
- fSendATCmd(@ComIO, @szATCmd)
- %lType = 0
-
- :GET_CLASS1_SP0
- %lRes = fWaitResponse(@ComIO, 1000)
- if (%lRes != 0)
- goto GET_CLASS1_SP1
-
- %szStr1 = "145"
- %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = 14400
- goto GET_CLASS1_SP1
- }
- %szStr1 = "96"
- %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = 9600
- goto GET_CLASS1_SP1
- }
- %szStr1 = "72"
- %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = 7200
- goto GET_CLASS1_SP1
- }
- %szStr1 = "48"
- %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = 4800
- goto GET_CLASS1_SP1
- }
- %szStr1 = "24"
- %lRes = fSkipSpaceStrStr(%szStr1, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = 2400
- goto GET_CLASS1_SP1
- }
-
- goto GET_CLASS1_SP0
-
- :GET_CLASS1_SP1
- fSleep(500)
- fFlushRxQueue(@ComIO)
- call SubSendCmdWaitResp("AT+FCLASS=0", "OK", 3000)
- fSetBaudRate(@ComIO, 2400)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- exit (%lType)
-
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- :GET_FAX_CLASS
- fHardFlowControl(@ComIO, 9)
- fSoftFlowControl(@ComIO, 0)
- fSetRTS(@ComIO)
-
- fSetBaudRate(@ComIO, 2400)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- fSleep(300)
-
- call SubSendCmdWaitResp("AT", "OK", 500)
- fSleep(500)
- fFlushRxQueue(@ComIO)
-
- call SubSendCmdWaitResp("AT", "OK", 500)
- fSleep(300)
- fFlushRxQueue(@ComIO)
-
- @szATCmd = "ATE0V1"
- fSendATCmd(@ComIO, @szATCmd)
- fSleep(300)
- fFlushRxQueue(@ComIO)
-
-
- // @szATCmd = "ATS0=0H0"
- // fSendATCmd(@ComIO, @szATCmd)
- // fSleep(1000)
- // fFlushRxQueue(@ComIO)
- //
- // @szATCmd = "ATE0V1&C1H0"
- // fSendATCmd(@ComIO, @szATCmd)
- // fSleep(1000)
- // fFlushRxQueue(@ComIO)
- //
-
-
- call SubSendCmdWaitResp("ATZ", "OK", 3000)
- fSleep(1000)
- fFlushRxQueue(@ComIO)
-
- call SubSendCmdWaitResp("ATE0V1", "OK", 3000)
- fSleep(150)
- fFlushRxQueue(@ComIO)
-
- call SubSendCmdWaitResp("ATS0=0H0E0", "OK", 3000)
- fSleep(150)
- fFlushRxQueue(@ComIO)
-
- call SubSendCmdWaitResp("ATE0V1&C1H0", "OK", 3000)
- fSleep(150)
- fFlushRxQueue(@ComIO)
-
-
- fFlushTxQueue(@ComIO)
- if (%lGRes != 0)
- exit (1000) // No modem exists. Return any number greater 512
-
- fFlushTxQueue(@ComIO)
- fFlushRxQueue(@ComIO)
- @szATCmd = "AT+FCLASS=?"
- fSendATCmd(@ComIO, @szATCmd)
- %lType = 0
-
- :GET_FAX_CLASS1
- %lRes = fWaitResponse(@ComIO, 3000)
- if (%lRes != 0)
- {
- exit (%lType)
- }
-
- // Yes, sth is the buffer, we need to compare it
- %szStr3 = "OK"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- exit (%lType) // OK
- }
-
- %szStr3 = "1"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = %lType + 1
- }
-
- %szStr3 = "2.0"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- {
- %lType = %lType + 4
- %szStr3 = "2,"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- %lType = %lType + 2
- }
- else
- {
- %szStr3 = "2"
- %lRes = fSkipSpaceStrStr(%szStr3, @RespBuffer)
- if (%lRes != 0)
- %lType = %lType + 2
- }
-
- goto GET_FAX_CLASS1
-
-
- //--------------------------------------------------------
- // Class 1 is 1
- // Class 2 is 2
- // Class 2.0 is 4
- //--------------------------------------------------------
- :GET_FAX_PREFRENCE
- exit(2)
-
- //----------------------------------------------------------------------
- // The result are return as dec.
- // dec 48 - Hex 0x30
- // dec 49 - Hex 0x31
- // dec 50 - Hex 0x32
- // dec 51 - Hex 0x33
- // dec 52 - Hex 0x34
- // dec 53 - Hex 0x35
- // dec 54 - Hex 0x36
- // dec 55 - Hex 0x37
- // dec 56 - Hex 0x38
- // dec 57 - Hex 0x39
- //----------------------------------------------------------------------
- :FAX_CAPABILITY_MAIN
- fSleep(400)
- fFlushTxQueue(@ComIO)
- fFlushRxQueue(@ComIO)
- @szATCmd = "AT+FDCC=?"
- fSendATCmd(@ComIO, @szATCmd)
- %lType = 0
- %szStr1 = ""
-
- // wait for response
- %lRes = fWaitResponse(@ComIO, 3000)
- if (%lRes != 0)
- {
- exit (%lType)
- }
-
- fParseFaxClassCap(@RespBuffer, %szStr1)
- fSleep(300)
- fFlushTxQueue(@ComIO)
- fFlushRxQueue(@ComIO)
- exit (%lType)
-
-
- :FAX_CAPABILITY_VR
- //
- // szStr1 is the source
- //
- // %lType = 49
- %szStr2 = substr(%szStr1, 0, 1)
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
- :FAX_CAPABILITY_BR
- // %lType = 51
- %szStr2 = substr(%szStr1, 1, 2)
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
- :FAX_CAPABILITY_WD
- // %lType = 48
- %szStr2 = substr(%szStr1, 2, 3)
- %szStr2 = fCharToInt()
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
- :FAX_CAPABILITY_LN
- // %lType = 50
- %szStr2 = substr(%szStr1, 3, 4)
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
- :FAX_CAPABILITY_DF
- // %lType = 48
- %szStr2 = substr(%szStr1, 4, 5)
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
- :FAX_CAPABILITY_EC
- // %lType = 48
- %szStr2 = substr(%szStr1, 5, 6)
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
- :FAX_CAPABILITY_BF
- // %lType = 48
- %szStr2 = substr(%szStr1, 6, 7)
- %lType = fCharToInt(%szStr2)
- exit (%lType)
-
-
-
-
- //----------------------------------------------------------------------
- //----------------------------------------------------------------------
- :GET_CLASS20_SPEED
- fSleep(400)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- call SubSendCmdWaitResp("AT+FCLASS=2.0", "OK", 3000)
- fSetBaudRate(@ComIO, 19200)
- fSleep(400)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- @szATCmd = "AT+FCC=?"
- fSendATCmd(@ComIO, @szATCmd)
- %lType = 0
-
- :GET_CLASS20_SP0
- %lRes = fWaitResponse(@ComIO, 1000)
- if (%lRes != 0)
- goto GET_CLASS20_SP1
-
- fParseFaxClassCap(@RespBuffer, %szStr1)
-
- :GET_CLASS20_SP1
- fSleep(500)
- fFlushRxQueue(@ComIO)
- call SubSendCmdWaitResp("AT+FCLASS=0", "OK", 3000)
- fSetBaudRate(@ComIO, 2400)
- fFlushRxQueue(@ComIO)
- fFlushTxQueue(@ComIO)
- exit (%lType)
-
-